//
//  Test10.cpp
//  CPPTest
//
//  Created by you5 Yi on 2021/9/14.
//

#include "Test10.hpp"
#include <iostream>
#include <string>
using namespace std;

class str {
    string s,p;
    public:str(string&a,string&b) {
        s=a;
        p=b;
    }

    int find()
    {
        int i=0,j=0;
        char *m=(char *)p.data(),*n=(char *)s.data();
        long sSize = s.size();
        long pSize = p.size();
        long cha = sSize-pSize;
        while (i<=cha)
        {
            while (*m++==*n++)
                if (++j==p.size())
                    return i;
            i++;
            m=(char *)p.data();
            j=0;
            n = &s[i];
        }
        return -1;
    }
};

void test10()
{
    string l = "你好呀";
    string j = "你你好呀";
    str a = str(j, l);
    int i = a.find();
    std::cout<<"index="<<i<<std::endl;
}
